//  JS用两个栈实现一个队列
//  理解为:先进先出
class Queue {
	constructor() {
		this.stack1 = []
		this.stack2 = []
	}
	push(val) {
		this.stack1.push(val)
	}
	pop() {
		if (this.stack2.length) {
			return this.stack2.pop()
		} else if (!this.stack1.length) {
			return -1
		} else {
			while (this.stack1.length) {
				this.stack2.push(this.stack1.pop())
			}
			return this.pop()
		}
	}
}
const queue = new Queue()
queue.push(1)
queue.push(2)
queue.push(3)
console.log(queue.pop())
console.log(queue.pop())
console.log(queue.pop())
